package com.jn.zhinongbao.adapter.adapter;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.viewpager2.adapter.FragmentStateAdapter;

import com.example.supportingagriculturaltreasures.fragment.FarmerCircleFragment;
import com.example.supportingagriculturaltreasures.fragment.MerchantHomeFragment;
import com.example.supportingagriculturaltreasures.fragment.MerchantPublishFragment;
import com.example.supportingagriculturaltreasures.fragment.MessageFragment;
import com.example.supportingagriculturaltreasures.fragment.ProfileFragment;

public class MerchantPagerAdapter extends FragmentStateAdapter {

    public MerchantPagerAdapter(@NonNull FragmentActivity fragmentActivity) {
        super(fragmentActivity);
    }

    @NonNull
    @Override
    public Fragment createFragment(int position) {
        switch (position) {
            case 0:
                return MerchantHomeFragment.newInstance();
            case 1:
                return FarmerCircleFragment.newInstance();
            case 2:
                return MerchantPublishFragment.newInstance();
            case 3:
                return new MessageFragment();
            case 4:
                return ProfileFragment.newInstance();
            default:
                return MerchantHomeFragment.newInstance();
        }
    }

    @Override
    public int getItemCount() {
        return 5;
    }
} 